package com.yjhealth.libs.core.webinterface.client;

import android.net.Uri;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

public class YjhealthCoreWebChromeClient extends WebChromeClient {
    private CoreClientInterface clientInterface;

    public YjhealthCoreWebChromeClient(CoreClientInterface clientInterface) {
        this.clientInterface = clientInterface;
    }

    @Override
    public void onProgressChanged(WebView view, int newProgress) {
        super.onProgressChanged(view, newProgress);
        if (clientInterface != null) {
            clientInterface.onProgressChanged(view, newProgress);
        }
    }

    @Override
    public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
        if (clientInterface != null) {
            return clientInterface.onShowFileChooser(webView, filePathCallback, fileChooserParams);
        } else {
            return super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
        }
    }
}
